//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using System;
using System.Configuration;

namespace EntLibContrib.Query.Configuration
{
	/// <summary>
	/// Configuration data defining ServiceQueryData.
	/// This configuration section adds the service name and address
	/// </summary>    
	public abstract class ServiceQueryData : QueryData
	{
		#region Constants
		private const string addressProperty = "address";
		private const string serviceProperty = "service";
		private const string methodProperty = "method";
		#endregion

		#region Properties
		/// <summary>
		/// Address of the service to use.
		/// </summary>
		/// <value>The address of the service.</value>
		[ConfigurationProperty(addressProperty, IsRequired = false)]
		public string Address
		{
			get { return (string)base[addressProperty]; }
			set { base[addressProperty] = value; }
		}

		/// <summary>
		/// Name of the service to use.
		/// </summary>
		/// <value>The name of the service.</value>
		[ConfigurationProperty(serviceProperty, IsRequired = true)]
		public string Service
		{
			get { return (string)base[serviceProperty]; }
			set { base[serviceProperty] = value; }
		}

		/// <summary>
		/// Name of the method to use.
		/// </summary>
		/// <value>The name of the method.</value>
		[ConfigurationProperty(methodProperty, IsRequired = true)]
		public string Method
		{
			get { return (string)base[methodProperty]; }
			set { base[methodProperty] = value; }
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initializes a new instance of the <see cref="ServiceQueryData"/> class.
		/// </summary>
		protected ServiceQueryData ()
		{
		}

		/// <summary>
		/// Initialize a new instance of the <see cref="ServiceQueryData"/> class with a name and the type of <see cref="IQuery"/>.
		/// </summary>
		/// <param name="name">The name of the configured <see cref="IQuery"/>.</param>
		/// <param name="type">The type of <see cref="IQuery"/>.</param>
		protected ServiceQueryData(string name, Type type)
			: this(name, type, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty)
		{
		}

		/// <summary>
		/// Initialize a new instance of the <see cref="ServiceQueryData"/> class.
		/// </summary>
		/// <param name="name">The name of the <see cref="ServiceQueryData"/>.</param>
		/// <param name="type">The type of <see cref="IQuery"/>.</param>
		/// <param name="customCommandName">Name of the custom command.</param>
		/// <param name="parameterSetName">Name of the parameter set.</param>
		/// <param name="address">The service address.</param>
		/// <param name="service">The service type name.</param>
		/// <param name="method">The service method.</param>
		protected ServiceQueryData(string name, Type type, string customCommandName, string parameterSetName, string address, string service, string method)
			: base(name, type, customCommandName, parameterSetName)
		{
			this.Address = address;
			this.Service = service;
			this.Method = method;
		}
		#endregion
	}
}